Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Strongly typed Cap'n Proto implementation for the browser and Node.js using TypeScript
The capnp-ts package is a TypeScript implementation of the Cap'n Proto serialization protocol. It allows for efficient serialization and deserialization of data, making it useful for applications that require high-performance data interchange.
Serialization
This feature allows you to serialize data into a Cap'n Proto message. The code sample demonstrates how to create a new message, initialize a structure, set a field, and serialize the message into an ArrayBuffer.
const capnp = require('capnp-ts');
const MyStruct = capnp.import('path/to/my-struct.capnp');
const message = new capnp.Message();
const myStruct = message.initRoot(MyStruct);
myStruct.setField('value');
const serializedData = message.toArrayBuffer();
Deserialization
This feature allows you to deserialize data from a Cap'n Proto message. The code sample demonstrates how to create a message from an ArrayBuffer, get the root structure, and retrieve a field value.
const capnp = require('capnp-ts');
const MyStruct = capnp.import('path/to/my-struct.capnp');
const serializedData = /* some ArrayBuffer */;
const message = new capnp.Message(serializedData);
const myStruct = message.getRoot(MyStruct);
const value = myStruct.getField();
Schema Definition
This feature allows you to define schemas using Cap'n Proto's schema language. The code sample shows how to import a schema defined in a .capnp file.
const capnp = require('capnp-ts');
const MyStruct = capnp.import('path/to/my-struct.capnp');
// Define a schema in a .capnp file
// struct MyStruct {
// field @0 :Text;
// }
protobufjs is a JavaScript implementation of Protocol Buffers, another efficient serialization protocol. It offers similar functionality to capnp-ts but uses Protocol Buffers' schema language and wire format.
flatbuffers is a serialization library that allows for efficient reading and writing of data without parsing/unpacking. It is similar to capnp-ts in terms of performance and use cases but uses a different schema language and format.
avsc is a JavaScript library for working with Avro data serialization. It provides similar functionality to capnp-ts but uses Avro's schema language and binary format.
A strongly typed Cap'n Proto implementation for the browser and Node.js using TypeScript.
Here's a quick usage example:
import * as capnp from 'capnp-ts';
import {MyStruct} from './myschema.capnp';
export function loadMessage(buffer: ArrayBuffer): MyStruct {
const message = capnp.Message.fromArrayBuffer(buffer);
return message.getRoot(MyStruct);
}
An extended readme is available on the project site: https://github.com/jdiaz5513/capnp-ts.
0.7.0 (2021-08-19)
capnpc-js
is being retired in favor of compiling
directly to js from capnpc-ts
instead. This makes the one compiler
serve both purposes; js-only users who are annoyed by the extra d.ts
files may simply delete them. This was done to work around bugs in
source-map-support that prevent importing capnp.js files when a
capnp.ts file is also present.FAQs
Strongly typed Cap'n Proto implementation for the browser and Node.js using TypeScript
The npm package capnp-ts receives a total of 486,145 weekly downloads. As such, capnp-ts popularity was classified as popular.
We found that capnp-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.